//根据ID获取元素
function $(id){
	return document.getElementById(id);
}
//根据ID获取值
function v(id){
	return $(id).value;
}

//检查是否为明细分类
function check_havechild(el)
{	
	var obj=$(el);
	var opt = obj.options[obj.selectedIndex];
	if(opt.className=="havechild")
	{
		alert("请选择明细分类");
		obj.focus();
		return false;
	}
	return true;
}
//打开新窗口
function openWin(url,width,height)
{
  var win = window.open(url,"选择已上传图片","width=" + width + ",height=" + height + ",resizable=1,scrollbars=yes,menubar=no,status=yes");
}
//非空验证
function isNotEmpty(el,el_name)
{
	var e=$(el);
	e.style.border="1px solid #9093BE";
	if (e.value==""){
		alert("请填写"+el_name);
		e.style.border="2px solid red";
		e.focus();
		return false;
	}else{
		return true;
	}
}
//英文元素非空验证
function isNotEmpty_Eng(el,el_name)
{
	var e=$(el);
	if(e!=null){
		if(!isNotEmpty(el,el_name)){
			return false;
		}
	}
	return true;
}
//编辑器内容非空验证
function isNotEditorEmpty(el,el_name){
	var editor = FCKeditorAPI.GetInstance(el);
	var content=editor.GetXHTML();
	if(content==""){
		alert("请填写"+el_name);
		editor.Focus();
		return false;
	}else{
		return true;
	}
}
//编辑器英文内容非空验证
function isNotEditorEmpty_Eng(el,el_name){
	var editor = FCKeditorAPI.GetInstance(el);
	if(editor!=null){
		if(!isNotEditorEmpty(el,el_name)){
			return false;
		}
	}
	return true;
}
//非必填选项验证
function isConfirm(el,el_name){
	var e=$(el);
	e.style.border="1px solid #9093BE";
	if(e.value=="" && !confirm(el_name+"为空值，您确定吗？")){
		e.style.border="2px solid red";
		e.focus();
		return false;
	}
	return true;
}
//验证http开头
function isHttp(el,el_name){
	var e=$(el);
	if(!(e.value.toLowerCase().substring(0,7)=="http://")){
		e.style.border="2px solid red";
		alert(el_name+"请以http://开头");
		e.value="http://";
		e.focus();
		return false;
	}
	return true;
}
//验证是否为数字
function isNumber(el,el_name){
	var e=$(el);
	if (e.value=="")
	{
		return true;
	}
	if(isNaN(e.value)){
		e.style.border="2px solid red";
		alert(el_name+"必须为半角数字");
		e.focus();
		return false;
	}
	return true;
}
//验证日期
function isDate(el,el_name)
{
	var e=$(el);
    var reg=/^(\d{4})([-])(\d{1,2})([-])(\d{1,2})/;
    if(!reg.test(e.value))
    {
		e.style.border="2px solid red";
        alert(el_name+"日期格式不正确!\n正确格式为:2009-01-01");
		e.focus();
        return false;
    }
	return true;
}


//验证长度
function isLonger(el,el_name,len){
	var e=$(el);
	if(e.value.length<len){
		e.style.border="2px solid red";
		alert(el_name+"长度应大于"+len+"位");
		e.focus();
		return false;
	}
	return true;
}
//验证新旧密码
function isEqual(el1,el1_name,el2,el2_name){
	var e1=$(el1);
	var e2=$(el2);
	if(e1.value!=e2.value){
		e2.style.border="2px solid red";
		alert(el1_name+"和"+el2_name+"不相等");
		e2.focus();
		return false;
	}
	return true;
}
//验证表单主函数
function checkForm(formname){
	var flag=false;
	switch(formname){
		case "addarticle":
			flag=checkform_addarticle();
			break;
		case "addproduct":
			flag=checkform_addproduct();
			break;
		case "addphoto":
			flag=checkform_addphoto();
			break;
		case "addspecial":
			flag=checkform_addspecial();
			break;
		case "addtype":
			flag=checkform_addtype();
			break;
		case "adduser":
			flag=checkform_adduser();
			break;
		case "website":
			flag=checkform_website();
			break;
		case "modifycomment":
			flag=checkform_modifycomment();
			break;
		case "modifyrecordcomment":
			flag=checkform_modifyrecordcomment();
			break;
		case "modifypwd":
			flag=checkform_modifypwd();
			break;
		case "modifyuser":
			flag=checkform_modifyuser();
			break;
		case "addreply":
			flag=checkform_addreply();
			break;
		case "addad":
			generalCode();
			flag=checkform_addad();
			break;
		case "login":
			flag=checkform_login();
			break;
		case "sqlinj":
			flag=checkform_sqlinj();
			break;
		case "imgpath":
			flag=checkform_imgpath();
			break;
		case "addtag":
			flag=checkform_addtag();
			break;
		case "additem":
			flag=checkform_additem();
			break;
		case "addjob":
			flag=checkform_addjob();
			break;
		case "addfriendlink":
			flag=checkform_addfriendlink();
			break;
		case "modifymember":
			flag=checkform_modifymember();
			break;
	}
	if(flag){
		document.forms[0].submit();
	}	
}
//各表单验证函数
//添加文章
function checkform_addarticle()
{
	return check_havechild("upper")&&isNotEmpty("title","标题")&&isNotEditorEmpty("content","内容");
}
//添加商品
function checkform_addproduct()
{
	return check_havechild("upper")&&isNotEmpty("productid","商品型号")&&isNotEmpty("productname","商品名称")&&isNotEditorEmpty("content","内容")&&isConfirm("productimg","商品图片");
}
//添加图片
function checkform_addphoto()
{
	return check_havechild("upper")&&isNotEmpty("photoname","图片名称")&&isNotEmpty("photoimg","图片地址")&&isNotEditorEmpty("content","内容");
}
//添加友情链接
function checkform_addfriendlink()
{
	return isNotEmpty("name","网站名称")&&isNotEmpty("url","网址")&&isHttp("url","网址")&&isNotEmpty("theorder","排序")&&isNumber("theorder","排序");
}
//添加广告
function checkform_addad()
{
	if($("ad_type").value=="1"){
		return isNotEmpty("ad_begintime","有效时间起")&&isNotEmpty("ad_endtime","有效时间止")&&isNotEmpty("ad_alt","替换文本")&&isNotEmpty("ad_link","链接");
	}
	if($("ad_type").value=="2"){
		return isNotEmpty("ad_begintime","有效时间起")&&isNotEmpty("ad_endtime","有效时间止")&&isNotEmpty("ad_alt","替换文本")&&isNotEmpty("ad_link","链接")&&isNotEmpty("ad_imgswf","图片地址")&&isNotEmpty("ad_imgswf_width","图片宽度")&&isNotEmpty("ad_imgswf_height","图片高度")&&isNumber("ad_imgswf_width","图片宽度")&&isNumber("ad_imgswf_height","图片高度");
	}
	if($("ad_type").value=="3"){
		return isNotEmpty("ad_begintime","有效时间起")&&isNotEmpty("ad_endtime","有效时间止")&&isNotEmpty("ad_imgswf","Flash地址")&&isNotEmpty("ad_imgswf_width","Flash宽度")&&isNotEmpty("ad_imgswf_height","Flash高度")&&isNumber("ad_imgswf_width","Flash宽度")&&isNumber("ad_imgswf_height","Flash高度")&&isNotEmpty("ad_alt","描述文本");
	}
	if($("ad_type").value=="4"){
		return isNotEmpty("ad_begintime","有效时间起")&&isNotEmpty("ad_endtime","有效时间止")&&isNotEmpty("ad_codes","代码")&&isNotEmpty("ad_alt","描述文本");
	}
}
//添加文章
function checkform_addjob()
{
	return check_havechild("upper")&&isNotEmpty("name","职位名称")&&isNotEmpty("place","工作地点")&&isNotEmpty("salary","薪酬")&&isNotEmpty("number","招聘人数")&&isNotEmpty("endtime","截止时间")&&isNotEditorEmpty("content","职位要求");
}
//生成广告代码
function generalCode(){
	var code='';
	if(v("ad_type")=="1"){
		code="<a href=\""+v("ad_link")+"\" target=\"_blank\">"+v("ad_alt")+"</a>";
	}else if(v("ad_type")=="2"){
		code="<a href=\""+v("ad_link")+"\" target=\"_blank\" title=\""+v("ad_alt")+"\">"+"<img src=\""+v("ad_imgswf")+"\" width=\""+v("ad_imgswf_width")+"\" height=\""+v("ad_imgswf_height")+"\" border=\"0\"/></a>";
	}else if(v("ad_type")=="3"){
		code += '<object width="'+ v("ad_imgswf_width") +'" height="'+ v("ad_imgswf_height") +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cabjavascript:void(0)version=7,0,19,0">';
		code += '<param name="movie" value="'+ v("ad_imgswf") +'">';
		code += '<param name="wmode" value="opaque">';
		code += '<param name="quality" value="autohigh">';
		code += '<embed width="'+ v("ad_imgswf_width") +'" height="'+ v("ad_imgswf_height") +'" src="'+ v("ad_imgswf") +'" quality="high"   type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" ></embed>';
		code += '</object>';

	}else{
		code=v("ad_codes");
	}
	$("ad_code").value=code;
}

//添加标签
function checkform_addtag()
{
	var inttype=parseInt(v("tag_type"));
	var flag=true;
	if(inttype<=4){
		flag=isNotEmpty("tag_name","标签名称")&&isNotEmpty("tag_tag","唯一标记")&&isNotEmpty("recordnumber","记录数量")&&isNumber("recordnumber","记录数量")&&isNotEmpty("titlelength","标题长度")&&isNumber("titlelength","标题长度")&&isNotEmpty("contentlength","内容长度")&&isNumber("contentlength","内容长度")&&isNotEmpty("template","模板");
		if(inttype<=3){
			flag=flag&&isNotEmpty("pagesize","每页记录数")&&isNumber("pagesize","每页记录数")
		}
	}else if(inttype==5){
		flag=isNotEmpty("tag_name","标签名称")&&isNotEmpty("tag_tag","唯一标记")&&isNotEmpty("ad_type","广告类型")&&isNotEmpty("ad_num","广告数量")&&isNumber("ad_num","广告数量")&&isNumber("ad_num","广告数量")&&isNumber("ad_width","宽度")&&isNumber("ad_height","高度")&&isNotEmpty("template","模板");
	}else if(inttype==6){
		flag=isNotEmpty("tag_name","标签名称")&&isNotEmpty("tag_tag","唯一标记")&&isNotEmpty("template","模板");
	}else if(inttype<=11){
		flag=isNotEmpty("tag_name","标签名称")&&isNotEmpty("tag_tag","唯一标记")&&isNotEmpty("template","模板");
		if (document.getElementsByName("idtype")[1].checked==true)
		{
			flag=flag&&isNotEmpty("record_id","记录ID")&&isNumber("record_id","记录ID");
		}
		flag=flag&&isNotEmpty("titlelength","标题长度")&&isNumber("titlelength","标题长度")&&isNotEmpty("contentlength","内容长度")&&isNumber("contentlength","内容长度");
	}else 	if(inttype==12){
		flag=isNotEmpty("tag_name","标签名称")&&isNotEmpty("tag_tag","唯一标记")&&isNotEmpty("template","模板")&&isNotEmpty("record_id","记录ID")&&isNumber("record_id","记录ID");
	}
	return flag;
}
//添加专题
function checkform_addspecial()
{
	return isNotEmpty("specialname","专题名称")&&isNotEmpty_Eng("specialengname","专题英文名称")&&isConfirm("specialimg","专题图片");
}
//添加分类
function checkform_addtype()
{
	var flag=isNotEmpty("name","分类名称")&&isNotEmpty_Eng("engname","分类英文名称")&&isNotEmpty("theorder","分类排序")&&isNumber("theorder","分类排序");

	if (v("fenlei")==4){
		flag=flag&&isNotEmpty("url","前台链接地址");
	}
	if (v("fenlei")<=3)
	{
		flag=flag&&isNotEmpty("perpage","每页记录数")&&isNumber("perpage","每页记录数")
	}
	return flag;
	
}
//添加用户
function checkform_adduser(){
	return isNotEmpty("name","用户名")&&isNotEmpty("password","密码")&&isNotEmpty("repassword","重复密码")&&isEqual("password","新密码","repassword","重复密码")&&isLonger("name","用户名",3)&&isLonger("password","密码",6)&&isNotEmpty("question","安全提问")&&isNotEmpty("answer","安全回答");
}
//修改会员资料
function checkform_modifymember(){
	return isNotEmpty("name","姓名");
}
//网站配置
function checkform_website(){
	return isNotEmpty("rz_title_chn","网站标题")&&isNotEmpty("rz_perpage_speciallist","专题列表每页记录数")&&isNumber("rz_perpage_speciallist","专题列表每页记录数");
}
//邮件配置
function checkform_email(){
	if(isNotEmpty("smtphost","SMTP服务器")&&isNotEmpty("smtpuser","邮箱登陆账号")&&isNotEmpty("smtppassword","邮箱登陆密码")&&isNotEmpty("smtpfromname","发送方名称")&&isNotEmpty("smtpmailto","接收通知邮箱")){
		document.getElementById("emailform").submit();
	}

}
//检查修改留言
function checkform_modifycomment(){
	return check_havechild("upper")&&isNotEmpty("title","留言标题")&&isNotEmpty("content","留言内容");
}
//检查修改评论
function checkform_modifyrecordcomment(){
	return isNotEmpty("title","留言标题")&&isNotEmpty("content","留言内容");
}
//检查修改密码表单
function checkform_modifypwd(){
	return isNotEmpty("oldpassword","原密码")&&isNotEmpty("password","新密码")&&isNotEmpty("repassword","重复新密码")&&isEqual("password","新密码","repassword","重复新密码")&&isNotEmpty("question","安全提问")&&isNotEmpty("answer","安全回答");
}
//检查修改用户
function checkform_modifyuser(){
	return isNotEmpty("name","用户名")&&isNotEmpty("question","安全提问")&&isNotEmpty("answer","安全回答");
}
//检查添加留言回复
function checkform_addreply(){
	return isNotEmpty("content","回复内容");
}
//检查登录
function checkform_login(){
	return isNotEmpty("name","用户名")&&isNotEmpty("password","密码")&&isNotEmpty("checkcode","验证码")&&isNotEmpty("question","安全提问")&&isNotEmpty("answer","安全回答");
}
//检查删除SqlInj
function checkform_sqlinj(){
	var flag=confirm('您确定要删除吗？');
	return flag&&checkselect("id");
}
function checkform_additem(){
	var flag=isNotEmpty("itemkey","唯一标识")&&isNotEmpty("name","中文名称")&&isNotEmpty("engname","英文名称")&&isNotEmpty("theorder","排序")&&isNumber("theorder","排序");
	var fieldtype=v("fieldtype");
	if (fieldtype=="radio" || fieldtype=="checkbox" || fieldtype=="select")
	{
		if (v("options")=="")
		{
			flag=isNotEmpty("options","选项列表");
		}
	}else{
		if (v("options")!="")
		{
			alert(fieldtype+"类型不用填写“选项列表”");
			flag=false;
		}
	}
	if (document.getElementsByName("iscategory")[0].checked==true)
	{
		if (fieldtype!="radio" && fieldtype!="checkbox" && fieldtype!="select"){
			alert("分类字段的字段类型只能是“单选/复选/下拉列表”");
			flag=false;
		}
	}
	return flag;
}
//检查路径替换
function checkform_imgpath(){
	return isNotEmpty("oldpath","原路径")&&isNotEmpty("newpath","新路径");
}
//检查删除日志
function checkLogDelete(){
	var flag=confirm('您确定要删除吗？')&&checkselect("id");
	if(flag){
		$("act").value="Remove";
		$("rzform").submit();
	}	
}
function checkLogClear(){
	var flag=confirm('您确定要清空所有日志吗？');
	if(flag){
		$("act").value="RemoveAll";
		$("rzform").submit();
	}
}
/*AJAX_检查是否用户名重复_BEGIN*/
function ajax_checkUsername()
{
	var date=new Date();
	stamp=date.getTime();
	var loader = new net.ContentLoader("user_test_duple.asp?name="+$("name").value+"&timestamp="+stamp,
		statechange_checkUsername,stateerror_checkUsername);	
}
function statechange_checkUsername()
{
	$("savebutton").disabled=false;
	$("exist").innerHTML="";
	var respText = this.req.responseText;
	if(respText=="exist")
	{
		$("exist").innerHTML="<span style='color:red;'>用户名重复</span>";
		document.getElementById("rzform").name.value="";
		document.getElementById("rzform").name.focus();	
	}
}
function stateerror_checkUsername(){
	$("exist").innerHTML="连接服务器出错";
	$("savebutton").disabled=true;
}
/*AJAX_检查是否用户名重复_END*/

/*AJAX_检查lang*/
function ajax_checkWord(module,thevalue)
{
	var date=new Date();
	stamp=date.getTime();
	var loader = new net.ContentLoader("search_ajax.asp?list="+module+"&keyword="+escape(thevalue)+"&timestamp="+stamp,
		statechange_checkWord,stateerror_checkWord);	
}
function statechange_checkWord()
{
	var respText = this.req.responseText;
	if (respText!="")
	{
		$("showlayer").style.display="";
		$("show").innerHTML=respText;
	}else{
		$("show").innerHTML="";
		$("showlayer").style.display="none";
	}
	
}
function stateerror_checkWord(){
	
}
/*AJAX_检查lang_END*/

/*AJAX_显示广告预览_BEGIN*/
function ajax_PreviewAD(id)
{
	var date=new Date();
	stamp=date.getTime();
	var loader = new net.ContentLoader("advertise_preview.asp?id="+id+"&timestamp="+stamp,
		statechange_PreviewAD,stateerror_PreviewAD);	
}
function statechange_PreviewAD()
{
	$("prevAD").innerHTML="";
	$("prevAD").style.display="";
	var e = window.event; 
	e.pageX
	var respText = this.req.responseText;
	$("prevAD").innerHTML=respText;
}
function stateerror_PreviewAD(){
	$("prevAD").innerHTML="连接服务器出错";
}

function hiddenprevAD(){
	$("prevAD").style.display="none";
}



/*AJAX_显示广告预览_END*/


//选择所有记录
function selectAll()  {
	var ids=document.getElementsByName("id");
	var selectall=$("selectall");
	for(i=0;i<ids.length;i++) {
		ids[i].checked=selectall.checked;   
		chkRow(ids[i]);
	}
}
//更改选中行的颜色
function chkRow(obj){
	var agt=navigator.userAgent.toLowerCase();
	var is_ie=(agt.indexOf("msie")!=-1 && document.all);
	if (is_ie)
	{
		var r = obj.parentElement.parentElement;
	}else{
		var r = obj.parentNode.parentNode;
	}
	if(obj.checked)
	{ 
		r.style.backgroundColor="#E6E9F2";
	}
	else {
		if(r.rowIndex%2==1)
			r.style.backgroundColor="";
		else 
			r.style.backgroundColor="#F5F5F5";
	}
}
//检查是否有选中
function checkselect(el_name)  {
	var ids=document.getElementsByName(el_name);
	for(i=0;i<ids.length;i++){   
		if(ids[i].checked==true){
			return true;
		}
	}
	alert("请选择记录");
	return false;
}
//批量删除
function deleteselect(){
	var flag=confirm('您确定要删除吗？');
	if(flag&&checkselect("id")){
		document.getElementById("rzform").action="batch_delete.asp";
		document.getElementById("rzform").submit();
	}
}
//批量设置专题
function specialselect(){
	var flag=confirm('您确定设置吗？');
	if(flag&&checkselect("id")){
		document.getElementById("rzform").action="batch_special.asp";
		document.getElementById("rzform").submit();
	}
}
//批量设置分类
function batchtype(){
	var flag=confirm('您确定修改吗？');
	if(flag&&checkselect("id")&check_havechild("upper")){
		document.getElementById("rzform").action="batch_type.asp";
		document.getElementById("rzform").submit();
	}
}
//设置广告类型
function setAdType(obj){
	var opt = obj.options[obj.selectedIndex];
	var tr_ad_link=$("tr_ad_link");
	var tr_ad_imgswf=$("tr_ad_imgswf");
	var tr_ad_imgswf_width=$("tr_ad_imgswf_width");
	var tr_ad_imgswf_height=$("tr_ad_imgswf_height");
	var tr_ad_code=$("tr_ad_code");
	var copyimg=$("copyimg");

	if(opt.value=="1")
	{
		tr_ad_link.style.display="";
		tr_ad_imgswf.style.display="none";
		tr_ad_imgswf_width.style.display="none";
		tr_ad_imgswf_height.style.display="none";
		tr_ad_code.style.display="none";
		copyimg.style.display="none";
	}
	if(opt.value=="2")
	{
		tr_ad_link.style.display="";
		tr_ad_imgswf.style.display="";
		document.getElementById("uploadframe").src="rzupload.asp?parentform=rzform&inputname=ad_imgswf";
		tr_ad_imgswf_width.style.display="";
		tr_ad_imgswf_height.style.display="";
		tr_ad_code.style.display="none";
		copyimg.style.display="";
	}
	if(opt.value=="3")
	{
		tr_ad_link.style.display="none";
		tr_ad_imgswf.style.display="";
		document.getElementById("uploadframe").src="rzupload.asp?parentform=rzform&inputname=ad_imgswf&ultype=flash";
		tr_ad_imgswf_width.style.display="";
		tr_ad_imgswf_height.style.display="";
		tr_ad_code.style.display="none";
		copyimg.style.display="none";
	}
	if(opt.value=="4")
	{
		tr_ad_link.style.display="none";
		tr_ad_imgswf.style.display="none";
		tr_ad_imgswf_width.style.display="none";
		tr_ad_imgswf_height.style.display="none";
		tr_ad_code.style.display="";
		copyimg.style.display="none";
	}	
}

//广告



/*更改上传文件目录*/
function changefolder(obj)
{
	var opt = obj.options[obj.selectedIndex];
	document.location="?subdir="+opt.value;
}
/*预览图片*/
function ajax_previewPhoto(photo)
{
	var el = $("photoviewer");
	el.innerHTML="<img src='../images/loading.gif'>";
	var date=new Date();
	stamp=date.getTime();
	var loader = new net.ContentLoader("fetchimage.asp?photo="+photo+"&timestamp="+stamp,statechange_previewPhoto,stateerror_previewPhoto);
}
function statechange_previewPhoto()
{
	var el = $("photoviewer");
	var respText = this.req.responseText;
	el.innerHTML=respText;
}
function stateerror_previewPhoto(){
	var el=$("photoviewer");
	el.innerHTML="连接服务器出错";
	el.innerHTML="";
}

function hidePhotoViewer()
{
	var el = $("photoviewer");
	el.innerHTML="";
}

/*AJAX_检查旧密码是否正确_BEGIN*/
function ajax_checkoldpwd()
{
	var date=new Date();
	stamp=date.getTime();
	var loader = new net.ContentLoader("user_test_userpassword.asp?password="+$("oldpassword").value+"&timestamp="+stamp,statechange_checkoldpwd,stateerror_checkoldpwd);

}
function statechange_checkoldpwd()
{
	$("msg").innerHTML="";
	var respText = this.req.responseText;
	if(respText=="fail"){
		$("msg").innerHTML="<br><span style='color:red;'>原密码不正确</span>";
		document.getElementById("rzform").oldpassword.value="";
		document.getElementById("rzform").oldpassword.focus();
	}
}
function stateerror_checkoldpwd(){
	$("msg").innerHTML="连接服务器出错";
}
function reset_checkoldpwd()
{
	$("msg").innerHTML="";
	$("oldpassword").value="";
	$("password").value="";
	return;
}
/*AJAX_检查旧密码是否正确_END*/

/*AJAX_图片选择器_BEGIN*/
function ajax_setFolder(obj)
{
	var opt = obj.options[obj.selectedIndex];
	var str=location.toString();
    var photobox=((((str.split("?"))[1]).split("="))[1]);
	var date=new Date();
  	stamp=date.getTime();
	var loader = new net.ContentLoader("selectphoto_listajax.asp?dir="+opt.value+"&photobox="+photobox+"&timestamp="+stamp,
		statechange_setFolder,stateerror_setFolder);
}
function statechange_setFolder()
{
	var respText = this.req.responseText;
	$("selectphotolist").innerHTML=respText;
}
function stateerror_setFolder(){
	$("selectphotolist").innerHTML="连接服务器出错";
}
function isIE(){
	var br =navigator.userAgent.toLowerCase();
	return /msie/.test(br)&&!/opera/.test(br);
}
function CopyPhoto(FilePath)
{
	var str=location.toString();
    var photobox=((((str.split("?"))[1]).split("="))[1]);
	if (isIE()) {
		window.opener.rzform(photobox).focus();							
		window.opener.document.rzform(photobox).value=FilePath;
		window.opener=null;
		window.close();
	} else {
		parent.opener.document.getElementById(photobox).value=FilePath;
		top.close();
	}
	
}
function PreviewPhoto(path)
{
	$("previewPhoto").innerHTML="";
	$("previewPhoto").innerHTML="<img src='"+path+"' alt='' style='width:200px;height:200px;border:0px;'/>";
}
/*AJAX_图片选择器_END*/

//后台管理首页
function framebutton(){
	var leftframediv = $('leftframediv');
	var switchicon = $('switchicon');
	var middleline = $('middleline');
	if(leftframediv.style.display == 'none'){
		leftframediv.style.display = '';
		switchicon.style.backgroundPosition = '0px';
		middleline.style.left='150px';
	}else{
		leftframediv.style.display = 'none';
		switchicon.style.backgroundPosition = '-11px';
		middleline.style.left='1px';
	}
}

//回复留言显示输入密码框
function showPwdInput(){
	if ($("mail_state").checked==true)
	{
		$("enterpwd").style.display='';
	}else{
		$("enterpwd").style.display='none';
	}
}

//左侧菜单展开收缩
function showLeftMenu(obj){
	var lms = document.getElementsByTagName("div");
	for (var i=0; i<lms.length; i++)
	{
		if (lms[i].id!="")
		{
			if (lms[i].id.indexOf("lm_")!=-1)
			{
				if (lms[i].id==obj)
				{
					if ($(obj).style.display=='none')
					{
						lms[i].style.display='';
					}else{
						lms[i].style.display='none';
					}
					
				}else{
					lms[i].style.display='none';
				}
			}
		}
	}/*
	var el = $(obj);
	if (el.style.display=='none')
	{
		el.style.display='';
	}else{
		el.style.display='none';
	}*/
}

//显示隐藏
function display_hidden(chbox,content){
	var cont = $(content);
	if(chbox.checked==true){
		cont.style.display="";
	}else{
		cont.style.display="none";
	}
}

//密码强度验证
function check_strength(pswfield_id, display_id) 
{
	
	var pswfield = $(pswfield_id);
	var displayfield = $(display_id);
	
	var input_str = pswfield.value;
	var input_length = input_str.length;
	
	if(input_str!=""){
		$("password_tips").style.display="";
	}else{
		$("password_tips").style.display="none";
	}
	
	var strength = 0;
	
	var number_reg; 
	number_reg = new RegExp("[0-9]");
	if (number_reg.test(input_str)) {
		strength++;
	}
	var non_alpha_reg;
	non_alpha_reg = new RegExp("[^A-Za-z0-9]");
	if (non_alpha_reg.test(input_str)) {
		strength++;
	}
	var upper_alpha_reg;
	upper_alpha_reg = new RegExp("[A-Z]");
	if (upper_alpha_reg.test(input_str)) {
		strength++;
	}
	
	if(input_length >=8) {
		strength++;
	}   
	
	var strength_str; 
	if (strength <= 1) {
		strength_str = '<strong style="color:blue">弱</strong>';
	} else if (strength <= 2) {
		strength_str = '<strong style="color:blue">中等</strong>';
	} else {
		strength_str = '<strong style="color:green">强壮</strong>';
	}
	if(input_str.length < 6) {
		strength_str = '<strong style="color:orange">太弱</strong>';
	}
	
	displayfield.innerHTML  = strength_str;
}

function previewHTML(){
	$("rzform").target="_blank";
	$("rzform").action="manage_template_preview.asp"
	$("rzform").submit();
}
function saveHTML(){
	var flag=true;
	var ftype=parseInt(document.getElementById("ftype").value);
	switch(ftype){
		case 0:
			if(v("file").indexOf(".html")==-1){
				alert("文件名后缀必须为.html");
				$("file").focus();
				flag=false;
			}
			break;
		case 1:
			if(v("file").indexOf(".css")==-1){
				alert("文件名后缀必须为.css");
				$("file").focus();
				flag=false;
			}
			break;
		case 2:
			if(v("file").indexOf(".js")==-1){
				alert("文件名后缀必须为.js");
				$("file").focus();
				flag=false;
			}
			break;
		case 3:
			if(v("file").indexOf(".xml")==-1){
				alert("文件名后缀必须为.xml");
				$("file").focus();
				flag=false;
			}
			break;
		case 4:
			if(v("file").indexOf(".txt")==-1){
				alert("文件名后缀必须为.txt");
				$("file").focus();
				flag=false;
			}
			break;
	}
	if(isNotEmpty("subdir","模板目录")&&isNotEmpty("file","文件名")&&isNotEmpty("content","模板内容")&&flag){
		$("rzform").action="manage_template_edit.asp"
		$("rzform").submit();
	}
}
function AddText(el,value){
	var t=$(el);
	t.focus();
	if(document.selection) 
		document.selection.createRange().text = value;
	else 
		t.value = t.value.substr(0, t.selectionStart) + value + t.value.substr(t.selectionEnd);
}


function showselected(selection,content,index){
	var cont = $(content);
	if(selection.selectedIndex==index){
		cont.style.display="";
	}else{
		cont.style.display="none";
	}
}
function templatefileupload(type,userdir){
	document.getElementById("templatefileupload").src="";
	if (type=="flash")
	{
		document.getElementById("templatefileupload").src="rzupload.asp?ultype=flash&Random=0&UserDir="+userdir;
	}else{
		document.getElementById("templatefileupload").src="rzupload.asp?ultype=image&Random=0&UserDir="+userdir;
	}
}

function checklisttype(el){
	if (el.options[0].selected==true)
	{
		var specialid=document.getElementById("specialid");
		specialid.options[1].selected=true;
		var flag=false;
		for (var i=1; i<el.options.length; i++)
		{
			if (el.options[i].selected==true)
			{
				flag=true;
				el.options[i].selected=false;
			}
		}
		if (flag==true)
		{
			alert("如果选择了“根据请求参数获取”，则不能选择其他分类");
		}
		
	}
}
function checkspecial(el){
	if (el.options[1].selected==true)
	{
		var typeids=document.getElementById("typeids");
		typeids.options[0].selected=true;
		for (var i=1; i<typeids.options.length; i++)
		{
			typeids.options[i].selected=false;
		}
	}
}


function paramdetails(type){
	var el = document.getElementById("paramdetail");
	if (type==0)
	{
		el.style.display="none";
	}else{
		el.style.display="";
	}
}


//复制到剪贴板，此段代码来自互联网
function toClipboard(txt) {    
     if(window.clipboardData) {    
             window.clipboardData.clearData();    
             window.clipboardData.setData("Text", txt);  
			 alert("复制成功！") 
     } else if(navigator.userAgent.indexOf("Opera") != -1) {    
          window.location = txt;    
     } else if (window.netscape) {    
          try {    
               netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");    
          } catch (e) {    
               alert("被浏览器拒绝！\n请在浏览器地址栏输入'about:config'并回车\n然后将'signed.applets.codebase_principal_support'设置为'true'");    
          }    
          var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);    
          if (!clip)    
               return;    
          var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);    
          if (!trans)    
               return;    
          trans.addDataFlavor('text/unicode');    
          var str = new Object();    
          var len = new Object();    
          var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);    
          var copytext = txt;    
          str.data = copytext;    
          trans.setTransferData("text/unicode",str,copytext.length*2);    
          var clipid = Components.interfaces.nsIClipboard;    
          if (!clip)    
               return false;    
          clip.setData(trans,null,clipid.kGlobalClipboard);    
          alert("复制成功！")    
     }    
}   
